package com.bao.work;

import java.util.Scanner;

public class Interface02 {
    public static void main(String[] args) {
        System.out.print("选择:");
        FightAble fightAble=Player.select(new Scanner(System.in).next());
        assert fightAble != null;
        fightAble.specialFight();
        fightAble.commonFight();
    }
}
interface FightAble{
    void specialFight();
    default void commonFight(){
        System.out.println("普通打击");
    }
}
class ZhanShi implements FightAble{

    @Override
    public void specialFight() {
        System.out.println("武器攻击");
    }
}
class Mage implements FightAble{

    @Override
    public void specialFight() {
        System.out.println("法术攻击");
    }
}
class Player{
    public static FightAble select(String str){
        if("法力角色".equals(str)){
            return new ZhanShi();
        }else if("武力角色".equals(str)){
            return new Mage();
        }
        return null;
    }

}
